﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Traceability_Management.Domain;
using Traceability_Management.ErrorCode;
using Traceability_Management.Read.Api.Application.Command.SlaughtsWay;
using Traceability_Management.Read.Api.Application.Command.SlaughtsWay_NextWay;

namespace Traceability_Management.Read.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class Slaughts_NextAllController : ControllerBase
    {
        IMediator mediator;

        public Slaughts_NextAllController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        [HttpPost]
        public async Task<ApiResult<int>> AddNextSlaughts(Slaughts_Next Slaughts_Next)
        {
            try
            {
                AddNextSlaughtsCommand AddNextSlaughtsCommand = new AddNextSlaughtsCommand() 
                {
                    Slaughts_Next= Slaughts_Next
                };
                return await mediator.Send(AddNextSlaughtsCommand);
            }
            catch (Exception)
            {
                throw;
            }
        }
        [HttpGet]
        public async Task<ApiResult<Slaughts_Next>> FirstNextSlaughts([FromQuery] FirstNextSlaughtsCommand FirstNextSlaughtsCommand)
        {
            try
            {
                return await mediator.Send(FirstNextSlaughtsCommand);
            }
            catch (Exception)
            {
                throw;
            }
        }
        [HttpPost]
        public async Task<ApiResult<int>> UpdateNextSlaughts(Slaughts_Next Slaughts_Next)
        {
            try
            {
                UpdateNextSlaughtsCommand UpdateNextSlaughtsCommand = new UpdateNextSlaughtsCommand()
                {
                    Slaughts_Next = Slaughts_Next
                };
                return await mediator.Send(UpdateNextSlaughtsCommand);
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
